<html>
<head>
<meta name=vs_targetSchema content="HTML 4.0">
<meta name="GENERATOR" content="Microsoft Visual Studio 7.0">
<LINK rel="stylesheet" type="text/css" href="dialog.css">
<script language="JavaScript">
function attr(name, value) {
	if (!value || value == "") return "";
	return ' ' + name + '="' + value + '"';
}
function insertImage() {
	window.returnValue = '<IMG' + attr("alt", alt.value) + attr("src", url.value)
							+ attr("align", align[align.selectedIndex].value)
							+ ((width.value)?attr("width", width.value):"")
							+ ((height.value)?attr("height", height.value):"")
							+ ((vspace.value)?attr("vspace", vspace.value):"")
							+ ((hspace.value)?attr("hspace", hspace.value):"")
							+ ((border.value)?attr("border", border.value):attr("border",0))
							+ '/>';
	window.close();
}
function cancel() {
	window.returnValue = null;
	window.close();
}


function setDefaults() {
   if (dialogArguments.RichEditor.selectedImage != null) {
      img = dialogArguments.RichEditor.selectedImage;
      editmode = true;
      fm = document.forms[0];
      if (img.src)
	  	 url.value = img.src
	  if  (img.alt)
	  	 alt.value = img.alt
	  if (img.width)
         width.value = img.width
      if (img.height)
         height.value = img.height
      if (img.vspace)
         vspace.value = img.vspace
      if (img.hspace)
         hspace.value = img.hspace
      if (img.border)
         border.value = img.border
      if (img.align) {
         for (var i = 0; i < align.options.length; i++) {
            if (align.options[i].value == img.align) {
               align.options[i].selected = true;
               break;
            }
         }        
      }
   }
   
   var img_array_id=dialogArguments.document.all("IMG_ATTACHMENT_ID").value.split(",");
   var img_array_name=dialogArguments.document.all("IMG_ATTACHMENT_NAME").value.split("*");
   var img_attach=document.all("img_attach");
   for(i=0;i<img_array_id.length;i++)
   {
      if(img_array_id[i]=="")
         continue;
      
      var oOption = document.createElement("option");
      img_attach.options.add(oOption,img_attach.options.length);
      oOption.innerText=img_array_name[i];
      oOption.value=img_array_id[i];
      
      var cur_src="/inc/attach.php?ATTACHMENT_ID="+img_array_id[i]+"&ATTACHMENT_NAME="+img_array_name[i];
      var img_src=img?img.src:"";
      
      if(img_src.substr(img_src.length-cur_src.length)==cur_src)
         oOption.selected=true;
   }
}

function updateImage() {
   img.alt = alt.value;
   img.src = url.value;
   img.width = width.value;
   img.height = height.value;
   img.vspace = vspace.value;
   img.hspace = hspace.value;
   img.border = border.value;
   img.align = align.options[ align.selectedIndex ].value;
   window.returnValue = null
   window.close();
}

var img = null     // selected image if there is one

// we need to set 
var editmode = false // are we editing an image?
if (dialogArguments.RichEditor.selectedImage != null) {
   editmode = true;
   document.write("<title>编辑图片</title>");
} else {
   document.write("<title>插入图片</title>");

}
function sel_img()
{
   var img_attach=document.all("img_attach");
   if(img_attach.value=="")
      return;
   document.all("url").value="/inc/attach.php?ATTACHMENT_ID="+img_attach.value+"&ATTACHMENT_NAME="+img_attach.options[img_attach.selectedIndex].innerText;
}
</script>

</head>

<body topmargin="0" leftmargin="0" style="border: 0; margin: 0;" scroll="no" onLoad="setDefaults()">
<table class="dlg" cellpadding="0" width="380" height="100%" cellspacing="0">
<tr><td colspan="2" width="78">图片信息&nbsp;</td>
	<td colspan="7" valign="middle" width="292"><hr width="100%"></td></tr>
<tr>
 <td width="10">　</td>
 <td width="68" align="right">附件图片:</td>
	<td colspan="7" valign="middle" width="292">
	 <select name="img_attach" onchange="sel_img();">
	   <option value="">选择图片</option>
	 </select>
	</td>
</tr>
<tr>
 <td width="10">　</td>
 <td width="68" align="right">位&nbsp;&nbsp;&nbsp; 置:</td>
	<td colspan="7" valign="middle" width="292"><input type="text" name="url" value="/images/logo.jpg" size="42"></td>
</tr>
<tr>
 <td height="10" width="10">&nbsp;</td>
 <td width="68" align="right">提示文字:</td><td colspan="7" valign="middle" width="292">
	<input type="text" name="alt" value="" size="42"></td>
</tr>
<tr>
 <td width="10">　</td>
 <td width="68" align="right">边&nbsp;&nbsp;&nbsp; 框:</td><td  colspan="3" width="102"> <input type="text" name="border" value="0" size="3"></td>
 <td width="68">
	<p align="right">对&nbsp;&nbsp;&nbsp; 齐:</td>
	<td  colspan="3" width="102">
	<select name="align">
		<option value="left">左对齐</option>
		<option value="absBottom">绝对底边对齐</option>
		<option value="absMiddle">绝对居中对齐</option>
		<option value="baseline">基线</option>
		<option value="bottom">相对底边对齐</option>
		<option value="middle">相对居中对齐</option>
		<option value="right">右对齐</option>
		<option value="textTop">文本上方</option>
		<option value="top">顶端对齐</option>
	</select></td>
</tr>
<tr>
 <td width="10">　</td>
 <td width="68" align="right">宽&nbsp;&nbsp;&nbsp; 度:</td><td valign="middle" width="22"><input type="text" name="width" value="" size="3"></td>
 <td width="48">
	<p align="right">高度:</td><td valign="middle" width="42"><input type="text" name="height" value="" size="3"></td>
 <td width="68">
	<p align="right">水平间距:</td><td valign="middle" width="22"><input type="text" name="vspace" value="0" size="2"></td>
 <td width="68">
	<p align="right">垂直间距:</td><td valign="middle" width="22"><input type="text" name="hspace" value="0" size="2"></td>
</tr>
<tr><td colspan="9"><hr width="100%"></td></tr>
<tr>
 <td>　</td>
 <td colspan="8" align="right">
<script language="JavaScript">
if (editmode) {
   document.write("<input class=\"button\" type=\"button\" value=\"更新\" title=\"更新图片\" onclick=\"updateImage()\">");
} else {
   document.write("<input class=\"button\" type=\"button\" value=\"插入\" title=\"插入图片\" onclick=\"insertImage()\">");
}
</script>
<input class="button" type="button" value="取消" title="取消" onclick="cancel()"></td>
</tr>
</table>
</body>
</html>